package main.chapter2

import java.lang.Exception

fun main(args: Array<String>) {
    try {
        val arg1 = args[0].toInt()
        val arg2 = args[1].toInt()
        println("$arg1+$arg2=${sum(arg1, arg2)}")
    } catch (e: ArrayIndexOutOfBoundsException) {
        println("请传入2个参数")
    } catch (e: NumberFormatException) {
        println("请确定传入的参数是整数")
    } catch (e: Exception) {
        println("程序出现未知异常${e.message}")
    } finally {
        println("感谢使用")
    }

}

private val sum = { arg1: Int, arg2: Int -> arg1 + arg2 }